var rootPath=null;

$(document).ready(function(){  
	rootPath=getRootPath();   
	odList();
});  
	

// function getRootPath(){
//     //获取当前网址，如： http://localhost:8083/uimcardprj/share/meun.jsp
//     var curWwwPath=window.document.location.href;
//     //获取主机地址之后的目录，如： uimcardprj/share/meun.jsp
//     var pathName=window.document.location.pathname;
//     var pos=curWwwPath.indexOf(pathName);
//     //获取主机地址，如： http://localhost:8083
//     var localhostPaht=curWwwPath.substring(0,pos);
//     //获取带"/"的项目名，如：/uimcardprj
//     var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
//     return(localhostPaht+projectName);
// }


 function odList(){
 	var cardId = window.sessionStorage.getItem("cardId");
// 	var examineeId = window.sessionStorage.getItem("examineeId");
 	var name = window.sessionStorage.getItem("name");


	
	$.ajax({
		    url : rootPath+"/getStudentBys",
		    type : "get",
		    dataType : "json",
		    data : {
		    	cardId:cardId,
//		    	examineeId:examineeId,
		    	name:name
		    },
		    cache : false,
		    async : false,
		    success : function(requestJson) {


		    if (requestJson.code > 0) {
	            var orderJson = requestJson.extend.student;
	            var htmlString_img = "";
	            if (orderJson.length != 0) {
	                for (var i = 1; i <= orderJson.length; i++) {
	                  // alert( orderJson[i]["school"]  +"!"+orderJson[i]["major"] +"!"+orderJson[i]["paytype"] +"!"+orderJson[i]["price"]);
	                  if(orderJson[i-1]["payType"]==2){
	                  	var payType ="未付费";
	                  	var style="style='color:#FCAC3E '";
	                  }else{
	                  	var payType ="已付费";
	                  	var style="style='color:#2EA9DF '";
	                  }		
//0  2  4  
	                  if(i%2==0){
	                  	var classType ="class='yk_list2'";
	                  }else{
	                  	var classType ="class='yk_list'";
	                  }							
	                  		var a=orderJson[i-1]['payType']+"";
	                  		var b=orderJson[i-1]['school']+"";
	                  		var c=orderJson[i-1]['major']+"";
	                  		var d=orderJson[i-1]['direction']+"";
	                  		var e=orderJson[i-1]['price']+"";
	                  		var f=orderJson[i-1]['id']+"";
	                  		//alert(a+"/"+b+"/"+c+"/"+d+"/"+e);

	                      // htmlString_img += "<div class='yk_list' onclick='tztz(\""+a+"\",\""+f+"\")'><div class='yk_list_left'><div class='yk_list_left_t'>"+orderJson[i]["school"]+"</div><div class='yk_list_left_d'>"+
	                      // orderJson[i]["major"]+"</div></div><div class='yk_list_right'><div class='yk_list_right_t' "+style+" >"+payType+"</div><div class='yk_list_right_d'>￥"
	                      // +orderJson[i]["price"]+"</div></div></div>"
	                      htmlString_img += "<div "+classType+" onclick='tztz(\""+a+"\",\""+f+"\")' ><div class='yk_list_1'>"+orderJson[i-1]["school"]+"</div><div class='yk_list_2'>"+
	                       orderJson[i-1]["major"]+"</div><div class='yk_list_3'>"+
							"<div class='yk_list_3_l'  "+style+" >"+payType+"</div><div class='yk_list_3_r'>￥" +orderJson[i-1]["price"]/100+"</div></div></div>"
	                }
	                  document.getElementById('orderList').innerHTML = htmlString_img;
	            }
	        }
		    }
		 });

//"+orderJson[i]["payType"]+","+orderJson[i]["school"]+","+ orderJson[i]["major"]+","+ orderJson[i]["direction"]+","+ orderJson[i]["price"]+"
 }
 
function tztz(i,id){
	if(i==2){
		//alert("未付费");
		window.sessionStorage.setItem("id", id);
		window.location.href="information.html";
	}else{
		//alert("已付费");
		window.sessionStorage.setItem("id", id);
		window.location.href="paymentdocument.html";
	}

}